package gant.ext

import gant.tools.ClassUtils
import org.codehaus.gant.GantBinding
import org.codehaus.gant.IncludeTargets

/**
 * @author Tommy Barker
 */
class IncludeTargetsWithStringAsClassName extends IncludeTargets {

    IncludeTargetsWithStringAsClassName(GantBinding binding) {
        super(binding)
    }

    /**
     * instead of evaluating the String as a groovy script, we evaluate it as a class name, if the class is not found
     * then we assume it is a script and have {@link IncludeTargets} take care of it
     *
     * @param s the class or script to import
     */
    @Override
    def leftShift(String s) {

        try {
            ClassUtils.forName(s)
        }catch(ClassNotFoundException ex) {}

        //probably a script then, let the parent take care of it
        super.leftShift(s)
    }
}
